package com.lg.common.utils;

import org.apache.commons.lang3.StringUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ValidateUtil {

    /**
     * 验证Email是否正确
     * @param email
     * @return
     */
    public static  boolean checkEmail(String email){
        if(StringUtils.isEmpty(email)){
            return true;
        }
        if(! email.matches("^[a-zA-Z0-9_\\.-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$")){
            return false;
        }

        return true;
    }

    /**
     * 验证是有特殊字符
     * @param strValue
     * @return false表示有特殊字符
     */
    public static boolean checkTextDataForNORMAL(String strValue){
        if(StringUtils.isEmpty(strValue)){
            return false;
        }
        String pattern = "[\\{\\}\\[\\]\\<\\>\\'\\%\\\\‘\\\\]";
        Pattern r = Pattern.compile(pattern);
        Matcher m = r.matcher(strValue);
        if (m.find()) {
            return false;
        }
        return true;
    }
}
